import random

# 定义扑克牌
suits = ['♠', '♥', '♣', '♦']
ranks = ['3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A', '2']
jokers = ['大王', '小王']

# 生成一副扑克牌
def generate_deck():
    deck = []
    for suit in suits:
        for rank in ranks:
            deck.append(suit + rank)
    deck.extend(jokers)
    return deck

# 洗牌
def shuffle_deck(deck):
    random.shuffle(deck)
    return deck

# 发牌
def deal_cards(deck):
    player1 = []
    player2 = []
    player3 = []
    bottom_cards = []

    for i in range(17):
        player1.append(deck.pop())
        player2.append(deck.pop())
        player3.append(deck.pop())

    bottom_cards = deck
    return player1, player2, player3, bottom_cards

# 显示玩家手牌和底牌
def show_cards(player1, player2, player3, bottom_cards):
    print("玩家 1 的手牌:", player1)
    print("玩家 2 的手牌:", player2)
    print("玩家 3 的手牌:", player3)
    print("底牌:", bottom_cards)

# 简单的出牌交互（仅模拟）
def play_game(player1, player2, player3, bottom_cards):
    current_player = 1
    while True:
        if current_player == 1:
            print("玩家 1 出牌，输入要出的牌（用逗号分隔，输入 'pass' 表示不出）:")
            input_cards = input().strip()
            if input_cards == 'pass':
                current_player = 2
                continue
            # 这里可以添加牌型判断和规则验证代码
            cards = input_cards.split(',')
            for card in cards:
                if card in player1:
                    player1.remove(card)
                else:
                    print("你没有这张牌，请重新出牌。")
                    continue
            if len(player1) == 0:
                print("玩家 1 获胜！")
                break
            current_player = 2
        elif current_player == 2:
            print("玩家 2 出牌，输入要出的牌（用逗号分隔，输入 'pass' 表示不出）:")
            input_cards = input().strip()
            if input_cards == 'pass':
                current_player = 3
                continue
            cards = input_cards.split(',')
            for card in cards:
                if card in player2:
                    player2.remove(card)
                else:
                    print("你没有这张牌，请重新出牌。")
                    continue
            if len(player2) == 0:
                print("玩家 2 获胜！")
                break
            current_player = 3
        elif current_player == 3:
            print("玩家 3 出牌，输入要出的牌（用逗号分隔，输入 'pass' 表示不出）:")
            input_cards = input().strip()
            if input_cards == 'pass':
                current_player = 1
                continue
            cards = input_cards.split(',')
            for card in cards:
                if card in player3:
                    player3.remove(card)
                else:
                    print("你没有这张牌，请重新出牌。")
                    continue
            if len(player3) == 0:
                print("玩家 3 获胜！")
                break
            current_player = 1


if __name__ == "__main__":
    deck = generate_deck()
    shuffled_deck = shuffle_deck(deck)
    player1, player2, player3, bottom_cards = deal_cards(shuffled_deck)
    show_cards(player1, player2, player3, bottom_cards)
    play_game(player1, player2, player3, bottom_cards)